import { createServer, Server, IncomingMessage, ServerResponse } from 'http'
import netTest from './netTest'
// 明确类型麻烦些，却会获得非常详细的语法提示
 
const server: Server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
    res.statusCode = 200
    let result = await netTest.telnet('10.98.34.192',7777)
    res.setHeader("Content-Type", "text/plain")
    res.end(result.toString())
})

const hostname: string = "127.0.0.1"
const port: number = 3333
server.listen(port, hostname, () => {
    console.log(`Server running at http://${hostname}:${port}/`)
})